﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TravelGenerator.BusinessObjects.ModelObjects;
using TravelGenerator.IBusinessLayer.TravelManagement;

namespace TravelGenerator.BusinessLayer.TravelManagement
{
    /// <summary>
    /// Classe permettant de gérer les pictures
    /// </summary>
    internal class BLPictures : BLTravelManagement, IBLPictures
    {
        #region Constructor

        /// <summary>
        /// Initializes a new instance of the <see cref="BLPictures"/> class.
        /// </summary>
        /// <param name="blMaster">The bl master.</param>
        internal BLPictures(BLTravelManagement blMaster = null) : base(blMaster)
        {

        }

        #endregion

        #region Methods

        /// <summary>
        /// Méthode permettant de créer une nouvelle picture.
        /// </summary>
        /// <returns></returns>
        public Pictures CreateNewPicture()
        {
            Pictures pic = new Pictures();            

            return pic;
        }

        /// <summary>
        /// Création d'une picture et ajout au context.
        /// </summary>
        /// <returns></returns>
        public Pictures CreateAndAddNewPicture()
        {
            Pictures pic = this.CreateNewPicture();

            this.ContextManager.Pictures.AddObject(pic);

            return pic;
        }

        /// <summary>
        /// Obtient l'image en fonction de l'id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public Pictures GetPictureByID(int id)
        {
            return (from p in this.ContextManager.Pictures
                    where p.PicturesID == id
                    select p).FirstOrDefault<Pictures>();
        }

        #endregion
    }
}
